home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / answers / motif-faq / part2 < prev    next >
Encoding:
Text File  |  1993-06-30  |  33.3 KB  |  870 lines

  1. Newsgroups: comp.windows.x.motif,news.answers,comp.answers
  2. Path: senator-bedfellow.mit.edu!enterpoop.mit.edu!gatech!howland.reston.ans.net!math.ohio-state.edu!caen!batcomputer!munnari.oz.au!newshost.anu.edu.au!csc.canberra.edu.au!news
  3. From: jan@ise.canberra.edu.au (Jan Newmarch)
  4. Subject: Motif FAQ (Part 2 of 5)
  5. Message-ID: <1993Jul1.011123.27917@csc.canberra.edu.au>
  6. Followup-To: comp.windows.x.motif
  7. Keywords: FAQ question answer
  8. Sender: news@csc.canberra.edu.au
  9. Reply-To: jan@ise.canberra.edu.au (Jan Newmarch)
  10. Organization: University of Canberra
  11. Date: Thu, 1 Jul 93 01:11:23 GMT
  12. Approved: news-answers-request@MIT.Edu
  13. Expires: +1 months
  14. Lines: 853
  15. Xref: senator-bedfellow.mit.edu comp.windows.x.motif:18407 news.answers:9856 comp.answers:1161
  16.  
  17. Archive-name: motif-faq/part2
  18. Last-modified: Wed July 1 1993
  19. Version: 3.6
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27. -----------------------------------------------------------------------------
  28. Subject: 29) TOPIC: MOTIF GENERATORS
  29.  
  30. -----------------------------------------------------------------------------
  31. Subject: 30)*  What prototyping tools are there to generate Motif code?
  32.  
  33. [Last modified: June 93]
  34.  
  35. Answer: [An FAQ is for "personal opinions" on these tools.  I don't think it
  36. is appropriate to give such opinions through this particular posting, so I
  37. haven't included any.]
  38.  
  39. `Prototyping tools' come in two forms: those that can be used to design the
  40. interface only (GUI builder), and those that go beyond this to give support
  41. for application code (User Interface Management Systems).  There are a number
  42. of commercial and non-commercial tools of both kinds that will support the
  43. Motif interface.  They include:
  44.  
  45. GUI builders:
  46.  
  47. Builder Xcessory
  48. iXBUILD (formerly X Build)
  49. ExoCODE/xm
  50. MOTIFATION
  51. X-Designer
  52. Druid
  53.  
  54.  
  55. UIMS:
  56.  
  57. WINTERP
  58. ALEX
  59. Widget Creation Library
  60. UIMX
  61. Serpent
  62. TeleUse
  63. XFaceMaker2
  64. MetaCard
  65. ezX User Interface Management System
  66.  
  67.  
  68. Some contact addresses are:
  69.  
  70. WINTERP: You may obtain the current source, documentation, and examples via
  71. anonymous ftp from host export.lcs.mit.edu: in directory contrib/winterp you
  72. will find the compress(1)'d tar(1) file winterp.tar.Z. If you do not have
  73. Internet access you may request the source code to be mailed to you by sending
  74. a message to winterp-source%hplnpm@hplabs.hp.com or hplabs!hplnpm!winterp-
  75. source.
  76.  
  77. Serpent: The S/W is free (anonymous ftp) from ftp.sei.cmu.edu.  For more info
  78. contact erik/robert at serpent-info@sei.cmu.edu.  This is no longer supported,
  79. and is apparently replaced by a commercial product called Alpha.
  80.  
  81. TeleUse: In the U.K., send mail to xtech@unipalm.co.uk or call +44 954 211862.
  82. In the US contact Telesoft at:
  83.  
  84. TeleSoft, 5959 Cornerstone Court West, San Diego, CA 92121-9891
  85.              Phone: +1 619-457-2700
  86.                     +1 619-452-1334 Fax
  87.              Email: guisales@telesoft.com (Sales),
  88.                     guisupport@telesoft.com (Customer Support)
  89.  
  90.  
  91. Builder Xcessory from ICS.  More details are available by sending a request to
  92. info@ics.com.  Address: ICS Inc., 201 Broadway, Cambridge MA 02139, Tel. (617)
  93. 621-0060, Fax. (617) 621-9555
  94.  
  95. X-Designer: From Imperial Software Technology in the UK.  Email address is
  96. sales@ist.co.uk.  (+44) 743 587055
  97.  
  98. Recently, V.I. Corporation have become the distributor for the X-Designer
  99. product in the United States.  In addition, IST and V.I. Corporation have
  100. developed a product called DVX-Designer that merges X-Designer with their GUI
  101. product called DataViews.  Other merged products are in the works.  For more
  102. information, people can contact:
  103.  
  104.         V.I. Corporation
  105.         47 Pleasant Street
  106.         Northampton, MA  01060
  107.         Phone: (413) 586-4144
  108.         Fax: (413) 586-3805
  109.         Email: vi@vicorp.com
  110.  
  111.  
  112. ExoCODE/xm: From Expert Object Corp., 7250 Cicero Avenue, Lincolnwood, IL
  113. 60646 (708)676-5555.
  114.  
  115. X Build: iXOS Software GmbH, Bretonischer Ring 12,
  116.         8011 Grasbrunn/Munich,
  117.         Germany,
  118.         email support@ixos.de or office@ixos.de,
  119.         phone ++49-89-46005 0
  120.  
  121. or in the US
  122.  
  123.         UniPress Software,
  124.         2025 Lincoln Hwy.,
  125.         Edison, NJ 08817,
  126.         phone 1-800-222-0550
  127.  
  128. ExoCode: From EXOC (Chicago, IL)
  129.  
  130. UIMX: Visual Edge Software Limited, 3870 Cote Vertu, St Laurent, Quebec, H4R
  131. 1V4, Phone: (514) 332-6430, Fax:   (514) 332-5914, or: Visual Edge Software
  132. Ltd., 101 First Street, Suite 443, Los Altos, CA 94022, Phone: (415) 948-0753,
  133. Fax:   (415) 948-0843
  134.  
  135. The Widget Creation Library: The distribution is available in several ways.
  136. The preferred approach it for you to get the compressed tar file using
  137. anonymous ftp from:
  138.  
  139.     export.lcs.mit.edu    (18.30.0.238) /contrib/Wcl.1.06.tar.Z
  140.  
  141.  
  142. XFaceMaker2: NSL -  Non Standard Logics S.A., 57-59, rue Lhomond, 75005  Paris
  143. - France, Phone: +33 (1) 43.36.77.50, Fax:   +33 (1) 43.36.59.78 email:
  144. requests@nsl.fr or requests%nsl.fr@inria.fr for information.
  145.  
  146. Their North American office: Non Standard Logics, Inc., 4141 State Street,
  147. Suite B-11, Santa Barbara CA 93110, Tel: 805 964 9599, Fax: 805 964 4367
  148.  
  149.  
  150. MOTIFATION: PEM GmbH, Vaihinger Strasse 49, 7000 Stuttgart 80, Germany, Tel:
  151. +49 (0) 711 713045, Fax: +49 (0) 711 713047 Email: basien@pem-stuttgart.de.
  152. Available for (Motif 1.2/1.1) on SunOS, Solaris 2.1, HP, Interactive, ODT 3.0,
  153. Silicon Graphics, PCS, ...
  154.  
  155.  
  156. ALEX: For more information contact Michael Karliner on (+44) 81 566 2307 or
  157. E-mail to alex@s-strat.co.uk.  ALEX Technologies, Waterman's Yard, 32a The
  158. Mall, Ealing, London W5, UK.
  159.  
  160. MetaCard: MetaCard 1.0 is supported on five popular UNIX/X11 platforms: SPARC,
  161. Sun3, DECstation, HP-9000/300, and SCO ODT.  An HP-9000/700 port is underway
  162. and should be available by the end of July.  [They] plan to support IBM
  163. RS/6000, SGI Iris, and DG AViiON sometime fall '92.  For more information, or
  164. to receive a free save-disabled but licensable copy of MetaCard, email to
  165. info@metacard.com or call 303- 447-3936.  If you have anonymous FTP access to
  166. the Internet, you can download the current engines, documentation, and an
  167. unlicensed Home stack from ftp.metacard.com (128.138.213.21), directory
  168. MetaCard.  Commercial users can get MetaCard from world.std.com
  169. (192.74.137.5), directory pub/Metacard.  If you don't have an anonymous ftp
  170. access, you can also download MetaCard from The World using kermit or xmodem
  171. from the ~ftp/pub/MetaCard directory.  Sign up by calling 617-739-0202 (voice)
  172. or via modem by dialing 617-739-9753 (7 bits even parity) and logging in as
  173. new.
  174.  
  175. MetaCard 1.2 Beta 5 is now available for anonymous FTP from ftp.metacard.com
  176. (directory MetaCard/1.2B5), and ftp.uu.net (directory vendor/MetaCard/1.2B5).
  177.  
  178. There is also a MetaCard mailing list.  To subscribe to the metacard-list,
  179. send mail to listserv@grot.starconn.com with the following commands in the
  180. body of the message:
  181.  
  182.       subscribe metacard-list firstname lastname
  183.       quit
  184.  
  185.  
  186. Replace "firstname lastname" with your name, not your e-mail address.
  187.  
  188.  
  189.  
  190. ezX User Interface Management System
  191. Sunrise Software, International
  192. 170 Enterprise Center
  193. Middletown, RI 02840
  194. 401-847-7868
  195. email: support@sunrise.com
  196.  
  197.  
  198.  
  199. WKSH (Windowing Korn Shell):
  200.  
  201.    EXtensible Korn Shell (C language calling interface,
  202.                           dynamic library loading, etc.)
  203.    Motif or OpenLook API
  204.    X Toolkit Intrinsics
  205.    WKSH Convenience Functions
  206.    Fast Learning and Prototyping Feature (ksh interpreter)
  207.  
  208.  
  209. Contact:
  210.    Acacia Computer,
  211.    PO Box 4376,
  212.    Warren, NJ 07059,
  213.    Phone: 908 548 6955,
  214.    Email: uunet!aca1
  215.  
  216. or
  217.  
  218. Computer Aid Inc, 1-(800)-444-WKSH
  219.  
  220. or
  221.  
  222. Consensys Corp, Europe: +(44)-734-833241 (Roger Chalke), +(44)0734-835391
  223. (Fax), US: (416)-940-2903, (416)-940-2903 (Fax).
  224.  
  225.  
  226. WKSH was developed by USL. Binaries are available through Acacia Computer for
  227. SUNOS, Solaris, SCO ODT, Intel SVR4.0
  228.  
  229.  
  230. Druid is a commercial product. It currently supports Motif1.1 and 4 unix
  231. platforms: SPARC, HP 9000, RS6000, and SGI.
  232.  
  233. For further information contact: Mr. Fred Lee, Automated Systems (Pte)
  234. Limited, 203 Henderson Road, #12-07/14, Henderson Industrial Park, Singapore
  235. 0315.  FAX: (65)272-2029
  236.  
  237. Or: Dr. Gurminder Singh (gsingh@iss.nus.sg), Institute of Systems Science,
  238. National University of Singapore
  239.  
  240.  
  241.  
  242.  
  243. -----------------------------------------------------------------------------
  244. Subject: 31) TOPIC: TEXT WIDGET
  245.  
  246. -----------------------------------------------------------------------------
  247. Subject: 32) Why does  pressing  <return> in a text widget do nothing?  This
  248. happens using Motif 1.0 when I have a text widget inside a bulletin board (or
  249. form) inside a dialog shell. (In Motif 1.1 it is fixed for both text and list
  250. widgets.)
  251.  
  252. Answer: In single line mode, pressing the <return> key usually invokes the
  253. activate() action, and in multi-line mode, the newline() action.  However,
  254. whenever a widget is the child of a bulletin board widget which is the child
  255. of a dialog shell, the bulletin board forces all of its children to translate
  256. <return> to the bulletin board action Return() which is usually associated
  257. with the default button of the dialog.  To restore the text actions of
  258. activate() or newline(), you need to overide the Return() action of the
  259. bulletin board.
  260.  
  261.  
  262.         /* declarations */
  263.         /* for a single line widget */
  264.         char newTrans[] = "<Key>Return : activate()";
  265.         /* for a multi line widget */
  266.         char newTrans[] = "<Key>Return : newline()";
  267.         XtTranslations transTable;
  268.  
  269.         /* in executable section */
  270.  
  271.         transTable = XtParseTranslationTable(newTrans);
  272.  
  273.         /* after creating but before managing text widget */
  274.  
  275.         XtOverrideTranslations(textWidget, transTable);
  276.  
  277.  
  278. -----------------------------------------------------------------------------
  279. Subject: 33) When I add text to a scrolling text widget how can I get the new
  280. text to show?
  281.  
  282. Answer: Use the call undocumented in Motif 1.0
  283.  
  284.         void XmTextShowPosition(w, position)
  285.         Widget w;
  286.         XmTextPosition position;
  287.  
  288. where the position is the number of characters from the beginning of the
  289. buffer of the text to be displayed. If you don't know how many characters are
  290. in the buffer, use another call undocumented in Motif 1.0
  291.  
  292.         position = XmTextGetLastPosition(w)
  293.  
  294.  
  295. -----------------------------------------------------------------------------
  296. Subject: 34)  Does the text widget support 16 bit character fonts?
  297.  
  298.  
  299. [Last modified: November 92]
  300.  
  301. Answer: R5 has support for 16 bit character sets, and Motif 1.2 uses that.
  302. Neither Motif 1.0 nor 1.1 support 16 bit sets.
  303.  
  304. -----------------------------------------------------------------------------
  305. Subject: 35) How can I stop the text widget from echoing characters typed?  I
  306. need to turn off echo for password input.
  307.  
  308. Answer: Use the modifyVerifyCallback to tell when input is received. Set the
  309. `doit' field in the XmTextVerifyCallbackStruct to False to stop the echo. In
  310. Motif 1.0 this will cause a beep per character: Live with it, because at 1.1
  311. you can turn it off.  Note that password hiding is inherently insecure in X -
  312. someone may have an X grab on the keyboard and be reading all characters typed
  313. in anyway.
  314.  
  315. Another solution often proposed is to set the foreground and background
  316. colours to be the same, effectively hiding the text.  This has a major flaw:
  317. someone may select the text (triple click the mouse to get the line), and then
  318. paste the password into say an xterm with *different* foreground and
  319. background colours.  This immediately shows the password.
  320.  
  321. -----------------------------------------------------------------------------
  322. Subject: 36)  How can I replace characters typed with say a `*'?  I want to
  323. replace input for password entry.
  324.  
  325. [Last modified: April 93]
  326.  
  327. Answer: In Motif 1.1 Use the modifyVerifyCallback to tell when input is
  328. received.  Set text->ptr in the callback structure to '*'. This does not work
  329. under 1.0 because of an oversight in which changes to this are ignored.  In
  330. Motif 1.0, what you can do is set the doit flag to 'false' so the text is not
  331. displayed. Then set a static boolean to True to prevent re-entrance.  Next
  332. call XmTextReplace() to display your '*'.  then reset your re-entrance flag to
  333. False.  XmTextReplace() will call the XmNmodifyVerify callback.  To prevent
  334. getting into an infinite loop, you need the re-entrance flag.
  335.  
  336. The following program from Dan Heller illustrates this:
  337.  
  338. --------------
  339. /* Written by Dan Heller.  Copyright 1991, O'Reilly && Associates.
  340.  * This program is freely distributable without licensing fees and
  341.  * is provided without guarantee or warranty expressed or implied.
  342.  * This program is -not- in the public domain.  This program appears
  343.  * in the Motif Programming Manual, O'Reilly Volume 6.
  344.  */
  345.  
  346. /* passwd.c -- prompt for a passwd.  Meaning, all input looks like
  347.  * a series of *'s.  Store the actual data typed by the user in
  348.  * an internal variable.  Don't allow paste operations.  Handle
  349.  * backspacing by deleting all text from insertion point to the
  350.  * end of text.
  351.  */
  352. #include <Xm/Text.h>
  353. #include <Xm/LabelG.h>
  354. #include <Xm/RowColumn.h>
  355. #include <ctype.h>
  356.  
  357. void check_passwd();
  358. char *passwd; /* store user-typed passwd here. */
  359.  
  360. main(argc, argv)
  361. int argc;
  362. char *argv[];
  363. {
  364.     Widget        toplevel, text_w, rowcol;
  365.     XtAppContext  app;
  366.  
  367.     toplevel = XtVaAppInitialize(&app, "Demos",
  368.         NULL, 0, &argc, argv, NULL, NULL);
  369.  
  370.     rowcol = XtVaCreateWidget("rowcol",
  371.         xmRowColumnWidgetClass, toplevel,
  372.         XmNorientation, XmHORIZONTAL,
  373.         NULL);
  374.  
  375.     XtVaCreateManagedWidget("Password:",
  376.         xmLabelGadgetClass, rowcol, NULL);
  377.     text_w = XtVaCreateManagedWidget("text_w",
  378.         xmTextWidgetClass, rowcol, NULL);
  379.  
  380.     XtAddCallback(text_w, XmNmodifyVerifyCallback, check_passwd, NULL);
  381.     XtAddCallback(text_w, XmNactivateCallback, check_passwd, NULL);
  382.  
  383.     XtManageChild(rowcol);
  384.     XtRealizeWidget(toplevel);
  385.     XtAppMainLoop(app);
  386. }
  387.  
  388. void
  389. check_passwd(text_w, unused, cbs)
  390. Widget        text_w;
  391. XtPointer     unused;
  392. XmTextVerifyCallbackStruct *cbs;
  393. {
  394.     char *new;
  395.     int len;
  396.  
  397.     if (cbs->reason == XmCR_ACTIVATE) {
  398.         printf("Password: %s\n", passwd);
  399.         return;
  400.     }
  401.  
  402.     if (cbs->text->ptr == NULL) { /* backspace */
  403.         cbs->endPos = strlen(passwd); /* delete from here to end */
  404.         if (cbs->endPos <= 0) return; /* catch null passwd - Mark Scoville */
  405.         passwd[cbs->startPos] = 0; /* backspace--terminate */
  406.         return;
  407.     }
  408.  
  409.     if (cbs->text->length > 1) {
  410.         cbs->doit = False; /* don't allow "paste" operations */
  411.         return; /* make the user *type* the password! */
  412.     }
  413.  
  414.     new = XtMalloc(cbs->endPos + 2); /* new char + NULL terminator */
  415.     if (passwd) {
  416.         strcpy(new, passwd);
  417.         XtFree(passwd);
  418.     } else
  419.         new[0] = NULL;
  420.     passwd = new;
  421.     strncat(passwd, cbs->text->ptr, cbs->text->length);
  422.     passwd[cbs->endPos + cbs->text->length] = 0;
  423.  
  424.     for (len = 0; len < cbs->text->length; len++)
  425.         cbs->text->ptr[len] = '*';
  426. }
  427.  
  428.  
  429. -----------------------------------------------------------------------------
  430. Subject: 37) How can I best add a large piece of text to a scrolled text
  431. widget?  In some versions of Motif 1.0 even using XmTextSetString, it insists
  432. on adding the text one line at a time, adjusting the scroll bar each time. It
  433. looks awful and is slow.
  434.  
  435. Answer: If you don't have this problem, use XmTextSetString to set all of the
  436. text in the widget.  If you do have this slowdown problem even using
  437. XmTextSetString, unmanage the widget, add the text and then manage it again.
  438. This may cause the window to blink, but you have to put up with that or switch
  439. to a different version of Motif.
  440.  
  441. -----------------------------------------------------------------------------
  442. Subject: 38) How can I highlight text in the Text widget?
  443.  
  444. Answer: From: argv@zipcode.com (Dan Heller)
  445.  
  446. If you don't need font or color changes, you can do all this using a Text
  447. widget very easily [in Motif 1.1, anyway].
  448.  
  449.         loop() {
  450.             pos = offset_of_pattern_in_text_widget(pattern, text_w);
  451.             search_len = strlen(pattern);
  452.             XmTextSetHighlight(text_w, pos, pos+search_len,
  453.                         XmHIGHLIGHT_SELECTED);
  454.         }
  455.  
  456.  
  457. There are two choices for highlighting: reverse video (HIGHLIGHT_SELECTED) and
  458. underlined (HIGHLIGHT_SECONDARY_SELECTED).  Be careful that your users won't
  459. confuse your highlights with actual selections!
  460.  
  461. -----------------------------------------------------------------------------
  462. Subject: 39)  How can I select all of the text in a widget programmatically?
  463. So that some initial text is displayed, but anything typed replaces it.
  464.  
  465. Answer: XmTextSetSelection(Text1, 0, XmTextGetLastPosition(Text1), event-
  466. >xbutton.time);
  467.  
  468. where Text1 is the widget in question (obviously) and event is some event that
  469. triggered this call.  You can use XtLastTimestampProcessed( display) instead
  470. of xbutton.time if you don't happen to have an event pointer handy.
  471.  
  472.  
  473.  
  474.  
  475. -----------------------------------------------------------------------------
  476. Subject: 40) How can I change colours of text in the Text widget?  I want some
  477. of the text in one colour, some in another.
  478.  
  479. Answer: You can't.  Text stores an ordinary string, and points where
  480. `highlights' of various types begin and end.  These highlights are all the
  481. control you have over components of the text.  See the previous question.
  482.  
  483.  
  484. -----------------------------------------------------------------------------
  485. Subject: 41) How can I change the font of text in the Text widget?  I want
  486. some of the text in one font, some in another.
  487.  
  488. Answer: You can't in Text (see the previous question).  If you wanted readonly
  489. text, you could do it by using a label instead.  Label uses XmStrings, which
  490. can contain multiple character sets in the one string.
  491.  
  492. -----------------------------------------------------------------------------
  493. Subject: 42) Is there an emacs binding for the text widget?
  494.  
  495. Answer: This set is due to Kee Hinckley (nazgul@alfalfa.com):
  496.  
  497. *XmText.translations: #override\n\
  498.         Ctrl <Key>b:            backward-character()\n\
  499.         Alt <Key>b:             backward-word()\n\
  500.         Meta <Key>b:            backward-word()\n\
  501.         Shift Alt <Key>b:       backward-word(extend)\n\
  502.         Shift Meta <Key>b:      backward-word(extend)\n\
  503.         Alt <Key>[:             backward-paragraph()\n\
  504.         Meta <Key>[:            backward-paragraph()\n\
  505.         Shift Alt <Key>[:       backward-paragraph(extend)\n\
  506.         Shift Meta <Key>[:      backward-paragraph(extend)\n\
  507.         Alt <Key><:             beginning-of-file()\n\
  508.         Meta <Key><:            beginning-of-file()\n\
  509.         Ctrl <Key>a:            beginning-of-line()\n\
  510.         Shift Ctrl <Key>a:      beginning-of-line(extend)\n\
  511.         Ctrl <Key>osfInsert:    copy-clipboard()\n\
  512.         Shift <Key>osfDelete:   cut-clipboard()\n\
  513.         Shift <Key>osfInsert:   paste-clipboard()\n\
  514.         Alt <Key>>:             end-of-file()\n\
  515.         Meta <Key>>:            end-of-file()\n\
  516.         Ctrl <Key>e:            end-of-line()\n\
  517.         Shift Ctrl <Key>e:      end-of-line(extend)\n\
  518.         Ctrl <Key>f:            forward-character()\n\
  519.         Alt <Key>]:             forward-paragraph()\n\
  520.         Meta <Key>]:            forward-paragraph()\n\
  521.         Shift Alt <Key>]:       forward-paragraph(extend)\n\
  522.         Shift Meta <Key>]:      forward-paragraph(extend)\n\
  523.         Ctrl Alt <Key>f:        forward-word()\n\
  524.         Ctrl Meta <Key>f:       forward-word()\n\
  525.         Ctrl <Key>d:            kill-next-character()\n\
  526.         Alt <Key>BackSpace:     kill-previous-word()\n\
  527.         Meta <Key>BackSpace:    kill-previous-word()\n\
  528.         Ctrl <Key>w:            key-select() kill-selection()\n\
  529.         Ctrl <Key>y:            unkill()\n\
  530.         Ctrl <Key>k:            kill-to-end-of-line()\n\
  531.         Alt <Key>Delete:        kill-to-start-of-line()\n\
  532.         Meta <Key>Delete:       kill-to-start-of-line()\n\
  533.         Ctrl <Key>o:            newline-and-backup()\n\
  534.         Ctrl <Key>j:            newline-and-indent()\n\
  535.         Ctrl <Key>n:            next-line()\n\
  536.         Ctrl <Key>osfLeft:      page-left()\n\
  537.         Ctrl <Key>osfRight:     page-right()\n\
  538.         Ctrl <Key>p:            previous-line()\n\
  539.         Ctrl <Key>g:            process-cancel()\n\
  540.         Ctrl <Key>l:            redraw-display()\n\
  541.         Ctrl <Key>osfDown:      next-page()\n\
  542.         Ctrl <Key>osfUp:        previous-page()\n\
  543.         Ctrl <Key>space:        set-anchor()\n
  544.  
  545.  
  546. ! If you'd like the Delete key to work like backspace instead of deleting
  547. ! backwards, add the following definition to the lines above.
  548. !       <Key>osfDelete: delete-previous-character()\n\
  549.  
  550. ! These aren't included because they could intefere with
  551. | menu accelerators (or vice versa)
  552. !       Alt <Key>p:             backward-paragraph()\n\
  553. !       Meta <Key>p:            backward-paragraph()\n\
  554. !       Shift Alt<Key>p:        backward-paragraph(extend)\n\
  555. !       Shift Meta<Key>p:       backward-paragraph(extend)\n\
  556. !       Alt <Key>w:             copy-clipboard()\n\
  557. !       Meta <Key>w:            copy-clipboard()\n\
  558. !       Ctrl Alt <Key>w:        cut-clipboard()\n\
  559. !       Ctrl Meta <Key>w:       cut-clipboard()\n\
  560. !       Alt <Key>y:             paste-clipboard()\n\
  561. !       Meta <Key>y:            paste-clipboard()\n\
  562. !       Alt <Key>f:             forward-word()\n\
  563. !       Meta <Key>f:            forward-word()\n\
  564. !       Alt <Key>n:             forward-paragraph()\n\
  565. !       Meta <Key>n:            forward-paragraph()\n\
  566. !       Shift Alt <Key>n:       forward-paragraph(extend)\n\
  567. !       Shift Meta <Key>n:      forward-paragraph(extend)\n\
  568. !       Shift Alt <Key>f:       forward-word(extend)\n\
  569. !       Shift Meta <Key>f:      forward-word(extend)\n\
  570. !       Alt <Key>d:             kill-next-word()\n\
  571. !       Meta <Key>d:            kill-next-word()\n\
  572. !       Alt <Key>h:             select-all()\n\
  573. !       Meta <Key>h:            select-all()\n\
  574.  
  575. Similar sets of translations have been suggested by others.
  576.  
  577. -----------------------------------------------------------------------------
  578. Subject: 43) How can I use a file as the text source for a Text widget?
  579.  
  580. Answer: You can't do it directly like you can with the Athena Text widget.
  581. Instead, read the text from the file into a string (all of it!) and then use
  582. XmTextSetString.  Alternatively, read blocks of characters and add them at the
  583. end of the text using XmTextInsertString.  The following is an excerpt from
  584. Dan Heller's "file_browser.c":
  585.  
  586.     /* file_browser.c -- use a ScrolledText object to view the
  587.      * contents of arbitrary files chosen by the user from a
  588.      * FileSelectionDialog or from a single-line text widget.
  589.      */
  590.  
  591.     ...
  592.     struct stat statb;
  593.  
  594.     /* make sure the file is a regular text file and open it */
  595.     if (stat(filename, &statb) == -1 ||
  596.             (statb.st_mode & S_IFMT) != S_IFREG ||
  597.             !(fp = fopen(filename, "r"))) {
  598.         if ((statb.st_mode & S_IFMT) == S_IFREG)
  599.             perror(filename); /* send to stderr why we can't read it */
  600.         else
  601.             fprintf(stderr, "%s: not a regular file0, filename);
  602.         XtFree(filename);
  603.         return;
  604.     }
  605.  
  606.     /* put the contents of the file in the Text widget by allocating
  607.      * enough space for the entire file, reading the file into the
  608.      * allocated space, and using XmTextFieldSetString() to show the file.
  609.      */
  610.     if (!(text = XtMalloc((unsigned)(statb.st_size+1)))) {
  611.         fprintf(stderr, "Can't alloc enough space for %s", filename);
  612.         XtFree(filename);
  613.         fclose(fp);
  614.         return;
  615.     }
  616.  
  617.     if (!fread(text, sizeof(char), statb.st_size+1, fp))
  618.         fprintf(stderr, "Warning: may not have read entire file!0);
  619.  
  620.     text[statb.st_size] = 0; /* be sure to NULL-terminate */
  621.  
  622.     /* insert file contents in Text widget */
  623.     XmTextSetString(text_w, text);
  624.  
  625.  
  626.  
  627.  
  628. -----------------------------------------------------------------------------
  629. Subject: 44) How can put Text in overstrike mode instead of insert?
  630.  
  631. Answer: There is no direct way. This was posted by Edmond Pitt
  632. (ejp@bohra.cpg.oz) The correct answer to the question is to put the following
  633. in a modifyVerify callback, where 'mvcb' is the XmTextVerifyCallbackStruct,
  634. and 'overstriking' is defined by you:
  635.  
  636.     if (overstriking && mvcb->text->length == 1)
  637.     {
  638.         _XmTextDisableRedisplay(w,FALSE);
  639.         XtCallActionProc(w,"delete-next-character",mvcb->event,0);
  640.         _XmTextEnableRedisplay(w);
  641.     }
  642.  
  643. _XmText{Dis,En}ableRedisplay() are XmText{Dis,En}ableRedisplay() in 1.0, but
  644. X11R3 has no XtCallActionProc() anyway. For this environment you need my 1.0.3
  645. Text widget patches posted last year & available on request.
  646.  
  647.  
  648. -----------------------------------------------------------------------------
  649. Subject: 45) How can I make the Delete key do a backspace?
  650.  
  651. Answer: Put this in your .Xdefaults
  652.  
  653.     *XmText.translations: #override <Key>osfDelete: delete-previous-character()
  654.  
  655.  
  656. -----------------------------------------------------------------------------
  657. Subject: 46) TOPIC: LIST WIDGET
  658.  
  659. -----------------------------------------------------------------------------
  660. Subject: 47) How do I best put a new set of items into a list?
  661.  
  662. Answer: Set the new list count and list by XtSetArgs and install them by
  663. XtSetValues.
  664.  
  665.     XmString list[SIZE];
  666.     int list_size;
  667.  
  668.     XtSetArg (args[n], XmNitemCount, list_size); n++;
  669.     XtSetArg (args[n], XmNitems, list); n++;
  670.     XtSetValues (w, args, n);
  671.  
  672. Each time the list is reset by this the old contents are freed by the widget
  673. and the new supplied list is copied.  Do *not* free the old list of items
  674. yourself as this would result in the space being freed twice.  It is not
  675. necessary to remove the items one at a time, nor to "zero" out the list first.
  676.  
  677. -----------------------------------------------------------------------------
  678. Subject: 48)  Can I have strings with different fonts in a list?
  679.  
  680. Answer: Yes. The strings are XmStrings. Each one can be created using a
  681. different character set using a different font.
  682.  
  683.  
  684. -----------------------------------------------------------------------------
  685. Subject: 49) Can I get a bitmap to show in a list item like I can in a Label?
  686. I want to place a bitmap along with some normal text in my list items.
  687.  
  688. Answer: No. The list contains XmStrings, and these only allow text in various
  689. character sets. The workaround is to define your font containing the icons you
  690. want. Then you can create a fontlist containing your icon font and the font
  691. you want the text in, and then make your items multi-segment XmStrings where
  692. the first segment contains the code of the icon you want with a charset that
  693. matches the icon font in your fontlist and the second segment with a charset
  694. matching the text font.
  695.  
  696.  
  697. -----------------------------------------------------------------------------
  698. Subject: 50) Can I have items with different colours in a list?
  699.  
  700. Answer: No.  The list contains XmStrings, and these only allow text in various
  701. character sets. Since the items are XmStrings, you can already change the font
  702. of an item by replacing it with an item with the same text and a different
  703. charset tag.  Adding support for color would require modification of the
  704. internal data structure in XmList as well as modification to the drawing
  705. routines.  A possible workaround is to use a rowcolumn of buttons which can be
  706. individually set.  However, you would have to do all list functionality
  707. yourself.
  708.  
  709.  
  710. -----------------------------------------------------------------------------
  711. Subject: 51) Can I grey out an item in a list?  I want to make insensitive
  712. items in a list so that they cannot be selected.
  713.  
  714. Answer:
  715.  
  716. From W. Scott Meeks of OSF:
  717.  
  718. Unfortunately, you can't do it directly since the list items aren't individual
  719. widgets.  We've had other requests for this technology, but it didn't make the
  720. cut for 1.2; it should be in some future release.
  721.  
  722. However, you can probably fake it in your application with some difficulty.
  723. First, a list item is an XmString, so you can specify a different charset for
  724. the item than for other items in the list and then specify a font in the
  725. list's fontlist that matches the charset and gives you the visual you want.
  726. The next problem is making the item unselectable.  One idea would be to have
  727. the application keep track of the insensitive items and the items currently
  728. selected.  Then you would set up a selection callback that when called would
  729. check the item selected against the list of insensitive items and if the
  730. selected item matched would deselect that item and reselect the previously
  731. selected items.  Otherwise it would just update the application's list of
  732. selected items.  The major drawback with this approach is that you'll get
  733. flashing whenever the list selects an item and your application immediately
  734. de-selects.  Unfortunately I can't think of a way around this without mucking
  735. with the list internals.
  736.  
  737. Another alternative suggested is to use instead a column of say read only text
  738. widgets which you can make insensitive.
  739.  
  740. -----------------------------------------------------------------------------
  741. Subject: 52)  Can I have multi-line items in a list?
  742. [Last modified: August 92]
  743.  
  744. Answer: Motif 1.0 and 1.1 both have problems with multi-line items in a list.
  745. They should work okay in Motif 1.2.
  746.  
  747. -----------------------------------------------------------------------------
  748. Subject: 53)+How can I tell the position of selected items in a list?
  749.  
  750. [Last modified: Oct 92]
  751.  
  752. Answer: From  W. Scott Meeks:
  753.  
  754. 1) All XmList selection callbacks get an XmListCallbackStruct which includes
  755. the item selected and its position.  In addition, the multiple and extended
  756. selection callbacks also get a list of the selected items.  This approach
  757. requires that your application saves this information if you need it outside
  758. of the immediate callback.
  759.  
  760. 2) At any time you can XtGetValues the XmNselectedItems and
  761. XmNselectedItemCount resources.  The problem with this approach is that
  762. identical items may or may not show up in multiple times in this list and the
  763. position in the selectedItems list may not relate directly to the position in
  764. the items list.
  765.  
  766. 3) You can call XmListGetSelectedPos on the list widget.  This will return a
  767. list of the positions of all selected items.
  768.  
  769. -----------------------------------------------------------------------------
  770. Subject: 54) TOPIC: FILE SELECTION BOX WIDGET
  771.  
  772. -----------------------------------------------------------------------------
  773. Subject: 55) What is libPW.a and do I need it?  My manual says I need to link
  774. in libPW.a to use the File Selection Box.  I can't find it on my system.
  775.  
  776. Answer: The libPW.a is the Programmers Workbench library which is an ATT
  777. product not included in Berkeley based systems, hence it is not found in SunOS
  778. or Ultrix, but is found on HP-UX (a Berkeley/ATT hybrid which chose ATT in
  779. this case).  It contains the regex(3) routines (regcmp, regex).  Some systems
  780. which don't have these in the libc.a need to link with -lPW.  Some systems
  781. which have the regex(3) routines in there also have the libPW.a.  If you have
  782. regex(3) in libc, and it works, don't link with libPW.  If you don't have
  783. regex(3) in libc, and you don't have a libPW, then check some sites on the net
  784. for public domain replacements (several exist), or call your vendor.
  785.  
  786. In most versions of Motif (see the doco), you can compile FileSB.c with
  787. -DNO_REGEX if you don't have it.
  788.  
  789. -----------------------------------------------------------------------------
  790. Subject: 56) What are these compile errors: Undefined symbol _regcmp and
  791. _regex?
  792.  
  793. Answer: You need to link in the libPW library - see previous question.
  794.  
  795.  
  796. -----------------------------------------------------------------------------
  797. Subject: 57) What's wrong with the Motif 1.0 File Selection Box?  I can't set
  798. the directory, change the directory or get the file mask to work.
  799.  
  800. Answer: The 1.0 File Selection Box is broken, and these don't work.  They
  801. weren't fixed until Motif 1.04.  Use these later versions of 1.0 or switch to
  802. Motif 1.1 where it changed a lot.
  803.  
  804. Joe Hildebrand has a work-around for some of this: Before popping up an
  805. XmFileSelectionDialog, change to the directory you want.  When a file is
  806. selected, check if it is a directory, so that we can change to it.  i.e.
  807.  
  808. static void show_file_box_CB(w, client_data, call_data)
  809.    Widget               w;
  810.    Widget               client_data;
  811.    XmAnyCallbackStruct  *call_data;
  812. {
  813.    chdir("/users/hildjj/files");
  814.    XtManageChild(client_data);
  815. }
  816.  
  817. static void val_save(w, client_data, call_data)
  818.    Widget       w;
  819.    Widget       client_data;
  820.    XmSelectionBoxCallbackStruct *call_data;
  821. {
  822.    struct stat buf;  /* struct stat is defined in stat.h */
  823.    char *filename;
  824.  
  825.    /* get the file name from the FileSelectionBox */
  826.    filename = SmX(call_data->value);
  827.  
  828.    /* get the status of the file named filename, and put it into buf */
  829.    if (!stat(filename, &buf))
  830.    {
  831.       /* if it's a directory */
  832.       /* if it's a directory */
  833.       if(S_ISDIR(buf.st_mode))
  834.       {
  835.          /* change to that directory, and update the FileSelectionBox */
  836.         chdir(filename);
  837.         XmFileSelectionDoSearch(w, NULL);
  838.       }
  839.       else
  840.          /* if it's a regular file */
  841.          if(S_ISREG(buf.st_mode))
  842.             /* ask if it should be overwritten */
  843.             XtManageChild(valbox);
  844.          else
  845.             /* it's another kind of file.  What type, i can't think of,
  846.                but it might happen */
  847.             pop_up_error_box(client_data, "Error saving file");
  848.    }
  849.    else  /* we couldn't get the file status */
  850.    {
  851.       /* if it's because the file doesn't exist, we're golden */
  852.       if (errno == ENOENT)
  853.          save_file();
  854.       else   /* there is some other problem getting the status.
  855.                 e.g. bad path */
  856.          pop_up_error_box(client_data, "Error saving file");
  857.    }
  858. }
  859.  
  860. this still doesn't implement the file masking stuff.
  861.  
  862.  
  863. -----------------------------------------------------------------------------
  864. END OF PART TWO
  865. --
  866. +----------------------+---+
  867.   Jan Newmarch, Information Science and Engineering,
  868.   University of Canberra, PO Box 1, Belconnen, Act 2616
  869.   Australia. Tel: (Aust) 6-2012422. Fax: (Aust) 6-2015041
  870.